home *** CD-ROM | disk | FTP | other *** search
/ Nejlepší hry / Nejlepsi hry.iso / hry / sea of chaos / sea_install.msi / _15C39AAA7726369D39812BD40F01CF6A / _820D75B480154A84B8F50E290C441B28 < prev    next >
Text File  |  2004-11-24  |  1KB  |  63 lines

  1. //simple shader to clip any pixels with a Z coordinate below the water plane
  2. //handles 2 directional lights and ambient
  3. //must be used with clipZ_lit.psh
  4. //Luke Lenhart
  5. //(C)2004-2005 Digipen Institute of Technology
  6.  
  7. //world,view,projection transform
  8. float4x4 matWorldViewProj;
  9. float4x4 matWorld;
  10.  
  11. //2 directional lights
  12. float4 l1Direction;
  13. float4 l1Color;
  14.  
  15. float4 l2Direction;
  16. float4 l2Color;
  17.  
  18. //ambient light
  19. float4 lAmbient;
  20.  
  21. //shader input
  22. struct VS_INPUT
  23. {
  24.     float4 Pos : POSITION;
  25.     float4 Normal : NORMAL;
  26.     float2 Tex0 : TEXCOORD0;
  27. };
  28.  
  29. //shader output
  30. struct VS_OUTPUT
  31. {
  32.     float4 Pos0 : POSITION;
  33.     float4 Pos1 : TEXCOORD1;
  34.     float2 Tex0 : TEXCOORD0;
  35.     float4 Color : COLOR;
  36. };
  37.  
  38. //shader code
  39. VS_OUTPUT VShader(VS_INPUT In)
  40. {
  41.     VS_OUTPUT Out;
  42.     
  43.     //calc colors from directional lights
  44.     float4 l1Contrib=dot(-In.Normal,l1Direction)*l1Color;
  45.     l1Contrib=saturate(l1Contrib);
  46.     
  47.     float4 l2Contrib=dot(-In.Normal,l2Direction)*l2Color;
  48.     l2Contrib=saturate(l2Contrib);
  49.     
  50.     Out.Color=l1Contrib + l2Contrib + lAmbient;
  51.     Out.Color.a=1.0f;
  52.     
  53.     //copy tex coord
  54.     Out.Tex0=In.Tex0;
  55.     
  56.     //calc transformed position
  57.     Out.Pos0=mul(matWorldViewProj,In.Pos);
  58.     Out.Pos1=mul(matWorld,In.Pos);
  59.  
  60.     //spit out the results
  61.     return Out;
  62. }
  63.